package com.wind.financial.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wind.common.annotation.Log;
import com.wind.common.core.controller.BaseController;
import com.wind.common.core.domain.AjaxResult;
import com.wind.common.enums.BusinessType;
import com.wind.financial.domain.Financialmanagement;
import com.wind.financial.service.IFinancialmanagementService;
import com.wind.common.utils.poi.ExcelUtil;
import com.wind.common.core.page.TableDataInfo;

/**
 * 财务账单Controller
 *
 * @author wind
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/car/financial")
public class FinancialmanagementController extends BaseController
{
    @Autowired
    private IFinancialmanagementService financialmanagementService;

    /**
     * 查询财务账单列表
     */
    @PreAuthorize("@ss.hasPermi('car:financialmanagement:list')")
    @GetMapping("/list")
    public TableDataInfo list(Financialmanagement financialmanagement)
    {
        startPage();
        List<Financialmanagement> list = financialmanagementService.selectFinancialmanagementList(financialmanagement);
        return getDataTable(list);
    }

    /**
     * 导出财务账单列表
     */
    @PreAuthorize("@ss.hasPermi('car:financialmanagement:export')")
    @Log(title = "财务账单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Financialmanagement financialmanagement)
    {
        List<Financialmanagement> list = financialmanagementService.selectFinancialmanagementList(financialmanagement);
        ExcelUtil<Financialmanagement> util = new ExcelUtil<Financialmanagement>(Financialmanagement.class);
        util.exportExcel(response, list, "财务账单数据");
    }

    /**
     * 获取财务账单详细信息
     */
    @PreAuthorize("@ss.hasPermi('car:financialmanagement:query')")
    @GetMapping(value = "/{FinancialID}")
    public AjaxResult getInfo(@PathVariable("FinancialID") Long FinancialID)
    {
        return success(financialmanagementService.selectFinancialmanagementByFinancialID(FinancialID));
    }

    /**
     * 新增财务账单
     */
    @PreAuthorize("@ss.hasPermi('car:financialmanagement:add')")
    @Log(title = "财务账单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Financialmanagement financialmanagement)
    {
        return toAjax(financialmanagementService.insertFinancialmanagement(financialmanagement));
    }

    /**
     * 修改财务账单
     */
    @PreAuthorize("@ss.hasPermi('car:financialmanagement:edit')")
    @Log(title = "财务账单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Financialmanagement financialmanagement)
    {
        return toAjax(financialmanagementService.updateFinancialmanagement(financialmanagement));
    }

    /**
     * 删除财务账单
     */
    @PreAuthorize("@ss.hasPermi('car:financialmanagement:remove')")
    @Log(title = "财务账单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{FinancialIDs}")
    public AjaxResult remove(@PathVariable Long[] FinancialIDs)
    {
        return toAjax(financialmanagementService.deleteFinancialmanagementByFinancialIDs(FinancialIDs));
    }
}
